<?php

/* @var $this \yii\web\View */
/* @var $content string */

use app\widgets\Alert;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<?php
    if(isset(yii::$app->user->identity)){
        $name = isset(yii::$app->user->identity->profile->name) ? Yii::$app->user->identity->profile->name : Yii::$app->user->identity->username;
    }else{
        $name = '';
    }
?>

<div class="wrap theme2">
    <?php
    NavBar::begin([
        'brandLabel' => '罗麦',
        'brandUrl' =>'#', //Yii::$app->homeUrl
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => [
            Yii::$app->user->can('member_index') ?
            ['label' => '会员管理', 'url' => ['/cruise/member/index']] : '',

            Yii::$app->user->can('cruise_index') ?
            ['label' => '邮轮管理', 'url' => ['/cruise/cruise/index']] : '',

            Yii::$app->user->can('people_index') ?
            ['label' => '统计管理', 'url' => ['/cruise/statis/index']]:'',

            Yii::$app->user->can('room_index') ?
            ['label' => '房间管理', 'url' => ['/cruise/room-use/index']] : '',
            
            Yii::$app->user->can('user_index') ? 
            ['label' => '账号管理', 'url' => ['/user/admin/index']] : '',

            Yii::$app->user->isGuest ? (['label' => '登录', 'url' => ['/user/login']] ) : 
                [   
                    'label' => $name,
                    'items' => [
                        '<li>'
                        . Html::beginForm(['/user/logout'], 'post')
                        . Html::submitButton(
                            '退出登陆',
                            ['class' => 'btn btn-link']
                        )
                        . Html::endForm()
                        . '</li>',
                    ],
                ]
        ],
    ]);
    NavBar::end();
    ?>

    <div class="container">
        <!-- ?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?-->
        <?= Alert::widget() ?>
        <div class="panel">
            <div class="panel-body">
            <?= $content ?>
            </div>
        </div>    
    </div>
</div>

<footer class="footer">
    <div class="container">
        <p class="pull-left">&copy; My Company <?= date('Y') ?></p>

        <p class="pull-right"><b>众信博睿（北京）国际商务会议展览有限公司</b></p>
    </div>
</footer>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
